package com.atguigu.mq.scheduled;

import com.atguigu.mq.constant.PunchConst;
import com.atguigu.mq.service.PunchClockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author KEIO  on 2021/9/5.
 * @version 1.0
 */

@Component
@EnableScheduling
@Slf4j
public class PunchTask {

    @Autowired
    RabbitTemplate rabbitTemplate;


    @Scheduled(cron = "0 0/5 * * * ?")  // 每五分钟执行一次
    public void taskPunch(){

       //TODO 发送消息
        log.info("定时任务开始发送消息了");
        rabbitTemplate.convertAndSend(PunchConst.EXCHANGE_DIRECT_TASK, PunchConst.ROUTING_TASK_8, "");

    }



}
